{extends 'base/site2.html'}
{block name="page_header"}{include file="common/header.html" inline}{/block}
{block name="page_nav"}{include file="common/slide-nav.html" inline}{/block}
{block name="page_styles"}
    <link rel="stylesheet" type="text/css" href="/css/common/daterangepicker-bs3.css" />
    <link rel="stylesheet" type="text/css" href="/css/mediation/caseallocate/index.css" />
<style>
.modal.in .modal-dialog{
    transform: translate(0,50%)!important;
}
</style>
{/block}
{block name="page_section"}
	<div class="sessionPage">
        <ul class="nav nav-tabs" style="width: 95%; margin:10px auto;">
            <li {if $type == 1} class="active"{/if}><a href="/caseallocate/index?type=1" style="color:#1D2129;font-size: 15px"><b>件数分配</b></a></li>
            <li {if $type == 2} class="active"{/if}><a href="/caseallocate/index?type=2" style="color:#1D2129;font-size: 15px"><b>人数分配</b></a></li>
        </ul>
    <form class="small-style" method="get" action="" role="validform" enctype="multipart/form-data">
      <div class="form_row">
        <input type="hidden" id='datatype' name="type" value="{$type}">
        <input type="hidden" name="limit" value="{if $query.limit}{$query.limit}{/if}">
<!--        <div class="form-group col-lg-3 ui-select">-->
<!--            <label for="exampleInputName2"  class="col-sm-4 control-label">调解部门:</label>-->
<!--            <div class="col-sm-7">-->
<!--                <select class="form-control selectpicker"    title="请选择" name="mediationOrganId">-->
<!--                    {foreach from=$mediationOrgan  item=info}-->
<!--                        <option class="u144_input_option" {if !empty($query.mediationOrganId) &&  $info.id== $query.mediationOrganId}selected="selected"{/if} value="{$info.id}">{$info.name}</option>-->
<!--                    {/foreach}-->
<!--                </select>-->
<!--            </div>-->
<!--        </div>-->
        <div class="form-group col-lg-3 ui-select">
            <label for="exampleInputName2"  class="col-sm-4 control-label">资产方:</label>
            <div class="col-sm-7">
                <select class="form-control selectpicker"    title="请选择" name="assetsId" id="assetsId">
                    {foreach from=$assets  item=info}
                        <option class="u144_input_option" {if !empty($query.assetsId) &&  $info.id== $query.assetsId}selected="selected"{/if} value="{$info.id}">{$info.name}</option>
                    {/foreach}
                </select>
            </div>
        </div>
        <div class="form-group col-lg-3 ui-select">
            <label for="exampleInputName2"  class="col-sm-4 control-label">导入批次ID:</label>
            <div class="col-sm-7">
                <input type="text" class="form-control noempty col-sm-4"  value="{if !empty($query.importRecordId)}{$query.importRecordId}{/if}" name="importRecordId" id="importRecordId" placeholder="请输入~">
            </div>
        </div>
          <div class="form-group col-lg-3 ui-select">
              <label for="exampleInputName2"  class="col-sm-4 control-label">批次名称:</label>
              <div class="col-sm-7">
                  <input type="text" class="form-control noempty col-sm-4"  value="{if !empty($query.batchName)}{$query.batchName}{/if}" name="batchName" id="batchName" placeholder="请输入~">
              </div>
          </div>
        <div class="form-group col-lg-3 ui-select">
            <label for="exampleInputName2"  class="col-sm-4 control-label">案件标识号:</label>
            <div class="col-sm-7">
                <input type="text" class="form-control noempty col-sm-4"  value="{if !empty($query.batshId)}{$query.batshId}{/if}" name="batshId" id="batshId" placeholder="请输入~">
            </div>
        </div>
      </div>
      <div class="form_row">
        <div class="form-group col-lg-3 ui-select">
            <label for="exampleInputName2"  class="col-sm-4 control-label">当事人:</label>
            <div class="col-sm-7">
                <input type="text" class="form-control noempty col-sm-4"  value="{if !empty($query.litigantName)}{$query.litigantName}{/if}" name="litigantName" id="litigantName" placeholder="请输入~">
            </div>
        </div>
        <div class="form-group col-lg-3 ui-select">
            <label class="col-sm-4 control-label">
                案件入库时间:
            </label>
            <div class="col-sm-7">
                <input data-ele="date" data-type="daterange" name="add_begin_end" class="form-control" placeholder="请选择" value="{if !empty($smarty.get.add_begin_end)}{$smarty.get.add_begin_end}{/if}" autocomplete="off"/>
            </div>
        </div>
          <div class="form-group col-lg-3 ui-select">
              <label for="exampleInputName2"  class="col-sm-4 control-label">一人多案:</label>
              <div class="col-sm-7">
                  <select class="form-control selectpicker"    title="请选择" name="caseLabel" id="caseLabel">
                      <option class="u144_input_option" {if !empty($query.caseLabel) &&  1== $query.caseLabel}selected="selected"{/if} value="1">是</option>
                      <option class="u144_input_option" {if !empty($query.caseLabel) &&  9== $query.caseLabel}selected="selected"{/if} value="9">否</option>
                  </select>
              </div>
          </div>
        <div class="form-group col-lg-3 ui-select">
            <div class="col-lg-5" style="float: right;">
                <button class="btn btn-primary col-lg-8 shousuoBtn "><span class="nav-icon glyphicon glyphicon-search" aria-hidden="true" style="margin-right: 2px"></span>查询</button>
            </div>
            <div class="col-lg-5">
                <a type="button" href="/caseallocate/index" class="btn btn-default col-lg-8 "><span class="nav-icon glyphicon glyphicon-refresh" aria-hidden="true" style="margin-right: 2px"></span>重置</a>
            </div>
        </div>
      </div>
    </form>
    <div style="width: 95%;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    overflow-x: scroll;">
        <table class=" table table-striped table-bordered table-hover text-nowrap" id="tab">
            <thead>
                <tr>
                    <th><input type="checkbox" class="checkall" style="vertical-align: text-bottom"></th>
                    <th>案件ID</th>
                    <th>调解部门</th>
                    <th>资产方</th>
                    <th>当事人</th>
                    <th>案件来源</th>
                    <th>调解号</th>
                    <th>借款平台</th>
                    <th>借款期数</th>
                    <th>欠款总额</th>
                    {if $type == 2}
                    <th>案件数</th>
                    {/if}
                    <th>逾期时间</th>
                    <th>入库时间入</th>
                    <th class="fix-ele">操作</th>
            </thead>
            <tbody>
                {foreach from=$arrList item=item name=foo}
                <tr>
                    <td> <input name="checkItem" class="j-check" type="checkbox" value="{$item.id}"></td>
                    <td>{$item.id}</td>
                    <td>{$mediationOrgan[$item.mediationOrganId]['name']}</td>
                    <td>{$assets[$item.assetsId]['name']} </td>
                    <td>{$item.litigantName}</td>
                    <td>{if $item.caseSource == 1}案件导入{else}案件推送{/if}</td>
                    {if $source == 1} <th>{$item.importRecordId}</th>{/if}
                    <td>{$item.mediationNum}</td>
                    <td>{$item.loanPlatform}</td>
                    <td>{$item.loanTerm}</td>
                    <td>{$item.debtTotal}</td>
                    {if $type == 2}
                        <td>{$item.caseNum}</td>
                    {/if}
                    <td>{$item.overdueDate|date_format:"%Y-%m-%d %H:%M:%S"}</td>
                    <td>{$item['addTime']|date_format:"%Y-%m-%d %H:%M:%S"}</td>
                    <td class="text-nowrap fix-ele">
                        <a href="/caseInfo/caseInfo?caseId={$item.id}">详情</a>
                        |<a class="caseallocateone"  data-toggle="modal" data-target="#allocate_meditor" href="javascript:;" data-id="{$item.id}">分配</a>
                    </td>
                </tr>
                {/foreach}
            </tbody>
        </table>
    </div>
    <div class="col-lg-12 pad-no mr-b20" style="float:none;">
        <button class="btn btn-primary caseallocateall" allocate-type="1" data-toggle="modal" data-target="#allocate_meditor">分配到调解员</button>
        <button class="btn btn-primary caseallocateall" allocate-type="2" data-toggle="modal" data-target="#allocate_origin">分配到部门</button>
    </div>
    <input type="hidden" value="" id="allocate_type">
    <input type="hidden" value="" id="allocate_ids">

    <div class="clearfix pad-no text-nowrap" style="margin-top: 20px;">
            {include file="base/pagenav.html"  action="/caseallocate/index" pagenum=$curPageNum inline}
            <select class="form-control" id="paglimit" style="float:right;margin:0 10px;width: auto;margin-top: -5px;">
                <option value="limit=10" {if $query.limit==10}selected="selected"{/if}>10条/页</option>
                <option value="limit=20" {if $query.limit==20}selected="selected"{/if}>20条/页</option>
                <option value="limit=50" {if $query.limit==50}selected="selected"{/if}>50条/页</option>
                <option value="limit=100" {if $query.limit==100}selected="selected"{/if}>100条/页</option>
                <option value="limit=500" {if $query.limit==500}selected="selected"{/if}>500条/页</option>
                <option value="limit=1000" {if $query.limit==1000}selected="selected"{/if}>1000条/页</option>
            </select>
            <span style="float:right;">共 {$totalnum} 条</span>
        </div>

    <div class="modal fade" id="allocate_origin" tabindex="-1" role="dialog" aria-labelledby="refusal_modal" aria-hidden="true">
        <div class="modal-dialog modal-dialog-centered" role="document">
            <div class="modal-content">

                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title" id="exampleModalLabel">分配案件到部门</h4>
                </div>
                <div class="modal-body">
                    <form id="entrustExpireTime_form">
                        <div class="form_dialog form-group col-lg-10 ui-select">
                            <label for="exampleInputName2"  class="col-sm-4 control-label">调解部门:</label>
                            <div class="col-sm-9">
                                <select class="form-control" id="mediationOrganId" name="mediationOrganId" >
                                    <option value="" >——请选择——</option>
                                    {foreach from=$mediationOrgan item=info}
                                        <option class="u144_input_option" value="{$info.id}">{$info.name}</option>
                                    {/foreach}
                                </select>
                            </div>
                        </div>

                        </br>
                    </form>

                </div>
                <div class="modal-footer" style="text-align: center;">
                    <button type="button" class="btn btn-default" id="fpclosebtn" data-dismiss="modal">取消</button>
                    <button type="button" class="btn btn-primary distribution">确定</button>
                </div>


            </div>
        </div>
    </div>

    <div class="modal fade" id="allocate_meditor" tabindex="-1" role="dialog" aria-labelledby="refusal_modal" aria-hidden="true">
        <div class="modal-dialog modal-dialog-centered" role="document">
            <div class="modal-content">

                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title" id="exampleModalLabel">分配案件到调解员</h4>
                </div>
                <div class="modal-body">
                    <form id="entrustExpireTime_form">
                        <div class="form_dialog form-group col-lg-10 ui-select">
                            <label for="exampleInputName2"  class="col-sm-4 control-label">调解员:</label>
                            <div class="col-sm-9">
                                <select class="form-control" id="mediators_id" name="mediators_id">
                                    <option value="" >——请选择——</option>
                                    {foreach from=$mediator item=info}
                                        <option class="u144_input_option" value="{$info.id}">{$info.name}</option>
                                    {/foreach}
                                </select>
                            </div>
                        </div>

                        </br>

                    </form>

                </div>

                <div class="modal-footer" style="text-align: center;">
                    <button type="button" class="btn btn-default" id="fpclosebtn" data-dismiss="modal">取消</button>
                    <button type="button" class="btn btn-primary distribution">确定</button>
                </div>


            </div>
        </div>
    </div>

{/block}
{block name="page_scripts"}
    <script type="text/javascript" src="/js/mediation/caseallocate/index.min.js" init="mediation/caseallocate/index"></script>
    <script type="text/javascript">
        $(".caseallocateall").on("click",function(){
            var arrbtn = [];
            $(".j-check:checked").each(function (index, ele) {
                //遍历所有复选框，然后取值进行 !非操作
                if ($(this).prop("checked")) {
                    arrbtn.push($(this).val());
                }
            })
            if(arrbtn.length==0){
                toastr.error('请选择案件');
                return false;
            }
            var ids=arrbtn.toString();
            $("#allocate_ids").val(ids);
            $("#allocate_type").val($(this).attr('allocate-type'));

        });

        $(".caseallocateone").on("click",function(){
            var ids=$(this).attr('data-id');
            $("#allocate_ids").val(ids);
            $("#allocate_type").val(1);

        });
        function GetQueryString(name){
            var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
            var r = window.location.search.substr(1).match(reg);
            if(r!=null)return  unescape(r[2]); return null;
        }
        $('body').on('change','#paglimit', function(){
            console.log()
            var mediationOrganId = GetQueryString('mediationOrganId');
            var type = GetQueryString('type');
            var paglimit = GetQueryString('limit');
            var val =  $(this).val();

            if(!mediationOrganId){
                if(!paglimit && type){
                    window.location = window.location.href+'&'+val;
                }else if(!paglimit){
                    window.location = window.location.href+'?'+val;
                }else{
                    window.location = window.location.href.replace('limit='+paglimit,val);
                }
            }else{
                if(!paglimit){
                    window.location = window.location.href+'&'+val;
                } else{
                    window.location = window.location.href.replace('limit='+paglimit,val);
                }
            }
        })

    </script>
{/block}
